# model 目录 CMakeLists.txt
# 收集所有源文件和头文件
file(GLOB_RECURSE MODEL_SOURCES "*.cpp")
file(GLOB_RECURSE MODEL_HEADERS "include/*.h" "include/*.hpp")

# 输出头文件与sources文件中分别包含哪些文件
message(STATUS "MODEL_HEADERS包含以下文件:")
foreach(header ${MODEL_HEADERS})
message(STATUS "${header}")
endforeach()

message(STATUS "MODEL_SOURCES包含以下文件:")
foreach(source ${MODEL_SOURCES})
message(STATUS "${source}")
endforeach()

# 创建模型库
add_library(model_lib SHARED ${MODEL_SOURCES} ${MODEL_HEADERS})

set_target_properties(model_lib PROPERTIES LINKER_LANGUAGE CXX)

# 设置包含目录
target_include_directories(model_lib
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
)

# 链接common_lib，因为模型可能依赖common库中的工具类
target_link_libraries(model_lib
PUBLIC common_lib
)

# 设置安装规则
install(TARGETS model_lib
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(DIRECTORY include/
DESTINATION include/model
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp"
)

# 输出提示信息
message(STATUS "已配置 model 库")
